package com.ThreadStudy.State;


/*
 *
 * 两个线程运行
 * 某一个到80次全部停止
 *
 * */

public class TestThreadStop1 implements Runnable{
    String Status; // 线程要的状态
    @Override
    public void run() {
        // 控制线程运行
        int i = 0;
        while (stopThread(Status)){
                System.out.println(Thread.currentThread().getName()+"线程运行次数:"+ (i++));
                if(i==10){
                    Status = "stop"; // 停止状态发送
                }
            }
        }


    public boolean stopThread(String Status){

        if(Status!=null){
            return false;
        }
        return true;
    }


    public static void main(String[] args) {

        TestThreadStop1 testThreadStop = new TestThreadStop1();

        new Thread(testThreadStop,"线程1").start();
        new Thread(testThreadStop,"线程2").start();

    }
}
